#ifndef STR_H
#define STR_H

#include <QObject>

class str : public QObject
{
    Q_OBJECT
public:
    explicit str(QObject *parent = nullptr);

    static qint8 char2Hex(char ch);
    static bool string2Hex(const QString &str, QByteArray *baHex);
    static void hex2Ascii(const QByteArray &hex, QByteArray *ascii);
    static void hex2String(const QByteArray &hex, QString *str);
    static QString stringTransfer(const QString &str); //字符串转义
    static bool byte32Swap(QByteArray &ba); //4字节的bytearray高低字节互换

    static void addCRC16(uint8_t *buffer, uint16_t n, uint16_t *pcrc);
    static uint8_t checkCRC16(uint8_t *buffer, uint16_t n);

signals:

public slots:
};

#endif // STR_H
